package com.admin.business.portalWebsite.venusHouseRentSell;

import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 房屋租售记录表
 * @create: 2023-11-21 14:18:29
 **/
@Service("venusHouseRentSellService")
@Slf4j
public class VenusHouseRentSellService{

    @Resource
    VenusHouseRentSellDao venusHouseRentSellDao;

    /**
     * 添加房屋租售记录表,获取id数据
     *
     * @param cdoRequest - id:主键id
     *                   - user_id:发布人id
     *                   - project_id:所属项目id
     *                   - room_id:房间id
     *                   - area_number:区号
     *                   - floor_number:楼号
     *                   - unit_number:单元号
     *                   - house_number:门牌号
     *                   - house_type:房屋类型
     *                   - built_area:面积
     *                   - text_title:文案标题
     *                   - release_type:发布类型1.租2.售
     *                   - house_types:户型
     *                   - total_floor:总楼层
     *                   - current_floor:所在楼层
     *                   - orientation:朝向1.东2.南3.西4.北
     *                   - renovation:装修1.精装修2.普通装修3.毛坯房
     *                   - elevator:电梯1.有2.无
     *                   - contact_name:联系姓名
     *                   - contact_number:联系电话
     *                   - month_rent_money:月租金额
     *                   - payment_method:付款方式
     *                   - build_time:建造时间
     *                   - square_meter_price:平方米单价
     *                   - total_money:总金额
     *                   - hearing_method:供暖方式1.集体供暖2.自采暖
     *                   - supporting_facilities:配套设施1.冰箱2.洗衣机3.空调4.电视5.沙发6.衣柜7.床8.宽带9.热水器10.燃气灶11.抽油烟机(多选)
     *                   - indoor_images:室内图
     *                   - house_images:户型图
     *                   - province_id:省
     *                   - city_id:市
     *                   - area_id:区
     *                   - jw_degree:经纬度
     *                   - position:位置
     *                   - house_introduction:房屋介绍
     *                   - rent_state:租状态1.未租2.已租3.下线
     *                   - sell_state:租状态1.未租2.已租3.下线
     *                   - update_time:更新时间
     *                   - begin_time:创建时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return addVenusHouseRentSell(CDO cdoRequest) {
        venusHouseRentSellDao.addVenusHouseRentSell(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("id")) {
            cdoResult.set("id", cdoRequest.get("id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据id，更新房屋租售记录表数据
     *
     * @param cdoRequest - id:主键id
     *                   - user_id:发布人id
     *                   - project_id:所属项目id
     *                   - room_id:房间id
     *                   - area_number:区号
     *                   - floor_number:楼号
     *                   - unit_number:单元号
     *                   - house_number:门牌号
     *                   - house_type:房屋类型
     *                   - built_area:面积
     *                   - text_title:文案标题
     *                   - release_type:发布类型1.租2.售
     *                   - house_types:户型
     *                   - total_floor:总楼层
     *                   - current_floor:所在楼层
     *                   - orientation:朝向1.东2.南3.西4.北
     *                   - renovation:装修1.精装修2.普通装修3.毛坯房
     *                   - elevator:电梯1.有2.无
     *                   - contact_name:联系姓名
     *                   - contact_number:联系电话
     *                   - month_rent_money:月租金额
     *                   - payment_method:付款方式
     *                   - build_time:建造时间
     *                   - square_meter_price:平方米单价
     *                   - total_money:总金额
     *                   - hearing_method:供暖方式1.集体供暖2.自采暖
     *                   - supporting_facilities:配套设施1.冰箱2.洗衣机3.空调4.电视5.沙发6.衣柜7.床8.宽带9.热水器10.燃气灶11.抽油烟机(多选)
     *                   - indoor_images:室内图
     *                   - house_images:户型图
     *                   - province_id:省
     *                   - city_id:市
     *                   - area_id:区
     *                   - jw_degree:经纬度
     *                   - position:位置
     *                   - house_introduction:房屋介绍
     *                   - rent_state:租状态1.未租2.已租3.下线
     *                   - sell_state:售状态1.未售2.下线
     *                   - update_time:更新时间
     *                   - begin_time:创建时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return updateVenusHouseRentSellById(CDO cdoRequest) {
        venusHouseRentSellDao.updateVenusHouseRentSellById(cdoRequest);
        return Return.SUCCESS;
    }

    /**
     * 根据id，删除房屋租售记录表数据
     *
     * @param cdoRequest - id:主键id
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return deleteVenusHouseRentSellById(CDO cdoRequest){
        int count = venusHouseRentSellDao.deleteVenusHouseRentSellById(cdoRequest.getLong("id"));
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除房屋租售记录表数据
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return deleteVenusHouseRentSell(CDO cdoRequest) {
        int count = venusHouseRentSellDao.deleteVenusHouseRentSell(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取房屋租售记录表数据
     *
     * @param cdoRequest - id:主键id
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return getVenusHouseRentSellById(CDO cdoRequest) {
        CDO cdoMapperResult = venusHouseRentSellDao.getVenusHouseRentSellById(cdoRequest.getLong("id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取房屋租售记录表数据列表
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return getVenusHouseRentSellListPage(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusHouseRentSellDao.getVenusHouseRentSellListPage(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusHouseRentSellDao.getVenusHouseRentSellCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
    /**
     * 根据混合条件，获取房屋租售记录表数据列表
     *
     * @param cdoRequest - id:主键id
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return getVenusHouseRentSellListPageByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusHouseRentSellDao.getVenusHouseRentSellListPageByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusHouseRentSellDao.getVenusHouseRentSellCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
}
